//==============================================================================
//
// Title:       ScreenRTC.c
// Purpose:     A short description of the implementation.
//
// Created on:  23/09/2010 at 08:37:36 by LEGRAND.
// Copyright:   GRPLEG. All Rights Reserved.
//
//==============================================================================

//==============================================================================
// Include files
#include "Screen_Start_1.h"


//==============================================================================
// Constants
//==============================================================================
// Types

//==============================================================================
// Static global variables

//==============================================================================
// Static functions
static unsigned char Screen_Start_1_OnInitialize( void );

static unsigned char Screen_Start_1_ProcessMessage( TMessage* pMsg );

//==============================================================================
// Global variables


//==============================================================================
// Global functions

const TScreen Screen_Start_1 =
{
	.ProcessMessage 	= Screen_Start_1_ProcessMessage,
	.OnInitialize   	= Screen_Start_1_OnInitialize,
};

static unsigned char Screen_Start_1_OnInitialize( void )
{


          if(Is_Battery_Present())
            {
                    LCD_Clear();
                    LCD_DrawString("    Press OK    ",1,LINE_1);
                    LCD_DrawString("    to start    ",1,LINE_2);
            }
          else{
                    Reset_By_Watchdog();
           }


  return 0U;
}

static unsigned char Screen_Start_1_ProcessMessage( TMessage* pMsg )
{

  	if( pMsg->ID == MSG_KEY_BOARD )
	{

		switch( pMsg->Param1 )
		{
                                          case KEY_OK:
                                          {

                                                  if(Is_Battery_Present())
                                                  {

                                                            if(GetFlag(FLAG_BATT1_PRESENT))
                                                            {
                                                              EE_Mode_1 = MODE_LOW;
                                                              Charge_Battery(BATTERY_1,EE_Mode_1);
                                                            }
                                                            if(GetFlag(FLAG_BATT2_PRESENT))
                                                            {
                                                              EE_Mode_2 = MODE_LOW;
                                                              Charge_Battery(BATTERY_2,EE_Mode_2);
                                                            }

                                                               SetTimerEvent(1);
                                                               SetFlag(FLAG_DRAW_VOLTAGE);      // flag pour timer 1min affichage volt
                                                               LCD_Clear();
                                                               Screen_SetCurrent(&Screen_Charge);

                                                  }
                                                  else
                                                  {
                                                            Reset_By_Watchdog();
                                                  }


                                          }
                                          break;
                                          case KEY_UP:
                                          {

                                          }
                                          break;
                                          case KEY_DOWN:
                                          {

                                          }
                                          break;
                                          case KEY_LEFT:
                                          {

                                          }
                                          break;
                                          case KEY_RIGHT:
                                          {

                                          }
                                          break;
                                }
                }
                else if( pMsg->ID == MSG_TIMER )
                  {
                         //Toggle_Led();
                  }
                  else
                  {

                   }



	return 0U;
}

